<template>
  <!-- 回到顶部 -->
    <div class="arrow-up"
    v-show="isShow"
    @click="topArrowUp">
      <van-icon name="arrow-up"/>
      <a href="JavaScript:;"></a>
    </div>
</template>

<script>
export default {
  name: 'TopShow',
  data () {
    return {
      // 显隐
      isShow: false
    }
  },
  created () {

  },
  mounted () {
    window.onscroll = () => {
      var top = window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0
      // console.log(top)
      if (top > 800) {
        this.isShow = true
      } else {
        this.isShow = false
      }
    }
  },
  methods: {
    // 回到顶部
    topArrowUp () {
      document.body.scrollTop = document.documentElement.scrollTop = 0
      this.isShow = false
    }
  }
}
</script>

<style scoped lang="less">
.arrow-up{
  position: fixed;
  top: 70%;
  left: 85%;
  // background-color: rgba(0,0,0,.3);
  width: 50px;
  height: 50px;
  .van-icon {
    position: absolute;
    top: 32%;
    left: 32%;
    z-index: 99;
    width: 50px;
    height: 50px;
  }
  a{
    position: absolute;
    display: inline-block;
    width: 80px;
    height: 80px;
    font-size: 12px;
    border-radius: 50% 50%;
    background-color: rgba(0,0,0,.3);
  }
}
</style>
